# first step:
# yum install ntp
# test cmd:
# date -s "2015-10-25 15:00:00"
import os
import time
import ntplib

client = ntplib.NTPClient()
res = client.request('pool.ntp.org')
tStr = time.localtime(res.tx_time)
date_str = time.strftime("%Y-%m-%d", tStr)
time_str = time.strftime("%H:%M:%S", tStr)

# the parameter of date -s, must be wrap by ""
cmd_date = "date -s \"{date} {time}\"".format(date=date_str, time=time_str)
# sync to bios
cmd_hwclock = "hwclock -w"
print(cmd_date)

os.system(cmd_date + " ; " + cmd_hwclock)
